#pragma once

#include <QThread>

#include <atomic>
#include <memory>

namespace base::tasking {

class TaskManager;
struct TaskCommand;

/**
 * @brief 工作线程，负责在后台执行任务
 */
class DbWorkerThread : public QThread {
    Q_OBJECT
public:
    explicit DbWorkerThread(TaskManager* manager, int index, QObject* parent = nullptr);
    ~DbWorkerThread() override;

    void stop();

protected:
    void run() override;

private:
    TaskManager* m_manager;
    int m_index = 0;
    std::atomic_bool m_stopRequested{false};
};

} // namespace base::tasking
